package day05;

import org.junit.Test;

import java.util.*;

public class MapTest {

    @Test
    public  void test() {
        Map map = new HashMap();
        map.put(123,"AA");
        map.put(123,"bb");
        map.put(53654,"AA");

        System.out.println(map);

        Map map1 = new HashMap();
        map1.put("cc",434);
        map1.put("ss",444);
        map.putAll(map1);
        System.out.println(map);

//        Object value = map.remove("cc");
//        Object value1 = map.remove("ccv");
//
//        System.out.println(value1);
//        System.out.println(value);
//        System.out.println(map);

//        map.clear();
//        System.out.println(map.size());

        System.out.println(map.get("ss"));
        System.out.println(map.get("sss"));

        Set set = map.keySet();
        Iterator iterator = set.iterator();
        while (iterator.hasNext()){
            System.out.println(iterator.next());
        }

        Collection values = map.values();
        for(Object obj : values){
            System.out.println(obj);

        }

        Set entrySet = map.entrySet();
        Iterator iterator1 = entrySet.iterator();
        while (iterator1.hasNext()){
            Object obj = iterator1.next();
            Map.Entry entry = (Map.Entry) obj;


        }

    }


    @Test
    public void test1(){

        List list = new ArrayList();
        list.add(435);
        list.add(7987);
        list.add(234);
        list.add(66634);
        list.add(0);

//        List dest = new ArrayList(10);
//        System.out.println(dest.size());
        List dest = Arrays.asList(new Object[list.size()]);
        System.out.println(dest.size());
        Collections.copy(dest, list);
        System.out.println(dest);


    }

    @Test
    public void test2(){
        ArrayList list = new ArrayList();
        list.add(213);
        list.add(3457889);
        list.add(96875);
        list.add(48966);


        for (Object obj : list){

            int stuScore = (int) obj;
            System.out.println(stuScore);

        }



    }


    @Test
    public void test3() {

        ArrayList<Integer> list = new ArrayList<Integer>();
        list.add(213);
        list.add(3457889);
        list.add(96875);
        list.add(48966);

        for (Integer score : list) {

            int stuScore = score;

            System.out.println(score);

        }

        Iterator<Integer> iterator = list.iterator();
        while (iterator.hasNext()){
            System.out.println(iterator.next());

        }



    }

    @Test
    public void test4() {
        Map<String,Integer> map = new HashMap<String, Integer>();
        map.put("tom",99);
        map.put("hdh",78);
        map.put("jack",55);
        Set<Map.Entry<String,Integer>> entry = map.entrySet();
        Iterator<Map.Entry<String,Integer>> iterator = entry.iterator();

        while(iterator.hasNext()){
            Map.Entry<String, Integer> e = iterator.next();


            System.out.println(e);


        }


    }



}




